package com.shyroke.daydayzhuanapi.entity;

import com.shyroke.daydayzhuanapi.dto.LabelDto;
import lombok.Getter;
import lombok.Setter;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;

@Getter
@Setter
@Entity
@Table(name = "app")
public class AppEntity extends BaseEntity implements Serializable {

    private String mark;

    private String inviteImg;

    private String inviteUrl;

    private String title;

    private String cover;

    private Date createTime;

    private Integer downCount;

    private Integer falseDownCount;

    private Integer offline;

    private Integer device;

    private String content;

    private Date updateTime;

    private Integer createId;

    private String companyName;

    private Integer type;

    private String withdraw;

    @ManyToMany(cascade = CascadeType.ALL)
    @JoinTable(name = "app_label",joinColumns = @JoinColumn(name = "app_id"),
            inverseJoinColumns = @JoinColumn(name = "label_id"))
    private List<LabelEntity> labelEntityList;

    @Transient
    private Integer realDownCount;
    @Transient
    private String keyword;
    @Transient
    private List<LabelDto> labelList = new ArrayList<>();

    public Integer getRealDownCount() {
        return (downCount==null?0:downCount)-(falseDownCount==null?0:falseDownCount);
    }
}